//
//  LocationTools.m
//  HiAugmentedWorld
//
//  Created by Jonathan Saggau on 4/12/10.
//  Copyright 2010 Sounds Broken inc. All rights reserved.
//

#import "LocationTools.h"


@implementation LocationTools

+(CLLocation *)locationForMarker;
{
    static CLLocation *locationForMarker;
    if(!locationForMarker)
    {
        CLLocationCoordinate2D coord;
        coord.latitude = MARKER_LAT;
        coord.longitude = MARKER_LONG;
        locationForMarker = [[CLLocation alloc] initWithCoordinate:coord 
                                                            altitude:MARKER_ALT 
                                                  horizontalAccuracy:50
                                                    verticalAccuracy:50
                                                           timestamp:[NSDate date]];
    }

    return locationForMarker;
}

+(float)angleFromCoordinate:(CLLocationCoordinate2D)first toCoordinate:(CLLocationCoordinate2D)second {
	float longitudinalDifference = second.longitude - first.longitude;
	float latitudinalDifference = second.latitude - first.latitude;
	float possibleAzimuth = (M_PI * .5f) - atan(latitudinalDifference / longitudinalDifference);
	if (longitudinalDifference > 0) return possibleAzimuth;
	else if (longitudinalDifference < 0) return possibleAzimuth + M_PI;
	else if (latitudinalDifference < 0) return M_PI;
	
	return 0.0f;
}

@end
